from selenium import webdriver
from lxml import  etree
from time import sleep
#实例化浏览器对象（传入浏览器驱动）
bro = webdriver.Chrome(executable_path='./chromedriver.exe')

#让浏览器发起一个指定URL请求
bro.get('https://q.stock.sohu.com/zs/000001/lshq.shtml')

#获取页面数据
page_text = bro.page_source

#解析历史股票数据
tree = etree.HTML(page_text)
tr_list = tree.xpath('//table[@id="BIZ_hq_historySearch"]/tbody/tr')
total = tr_list[:1]
total_text = total[0].xpath('./td')[0]
total_head = total_text.text
print("=:%s" % total_head)

for tr in tr_list[1:]:
    td_text = tr.xpath('./td')[0]
    date = td_text.text
    print(date)

sleep(1)

bro.quit()
